package com.wys.spring.db;

import org.aopalliance.aop.Advice;
import org.jetbrains.annotations.NotNull;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;

import java.lang.reflect.Method;

public class DataSourcePointcutAdvisor extends StaticMethodMatcherPointcutAdvisor {


    public DataSourcePointcutAdvisor(Advice advisor) {
        this.setAdvice(advisor);
    }

    @Override
    public boolean matches(Method method, @NotNull Class<?> targetClass) {
        return method.isAnnotationPresent(DataSource.class) || targetClass.isAnnotationPresent(DataSource.class);
    }
}
